<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>7_1_3-1-独立响应式值Ref</title>
</head>

<body>


  <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
  <div id="Application"></div>
  <script>
    const App = Vue.createApp({
      setup() {
        //定义响应式独立值
        let myObject = Vue.ref(10);
        //需要注意，myObjiect会自动包装对象，其中定义value属性为原始值
        function click() {
          myObject.value += 1;
          console.log(myObject.value);
        }
        //返回的数据myObject在模板中使用时已经是独立值
        return {
          myObject,
          click,
        };
      },
      template: `
            <h1>测试数据：{{myObject}}</h1>
            <button @click="click">点击</button>
            `,
    });
    App.mount("#Application");
  </script>
</body>

</html>